/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.io.StringReader;
import java.util.HashSet;

/**
 *
 * @author wei
 */
public class Fixtures {

    //please do not change the password for admin. This is used for testing forwarding internal message to email
    public static StringReader users = new StringReader(
            "thanh,ngan,12345,u0807217@nus.edu.sg\n"
            + "lee,password,9999,luwei.here@gmail.com\n"
            //         + "ngan,ngan,9999,letanthanh273@gmail.com,salesEmployee,SaleLead,SaleInquiry\n"
            + "dan,password2,234529,luweidewei@hotmail.com\n"
            + "admin,@asdqwe123,999,staff.merlion@gmail.com\n"
            + "jason,12345,234234,lala@msn.com\n"
            + "leticia,mypassword,98260973,mumdontbeatme@msn.com\n"
            + "feist,password,87654,luweidewei@gmail.com\n"
            + "ed,asd,123,edddieyap@gmail.com\n"
            + "nga,nga,123,thanh@gmail.com\n"
            + "than,than,123,letanthanh273@gmail.com\n"
            + "god,god,234234,lala1@msn.com\n");

    public static enum Right {
        //saleslead

        AddSalesLead("Add Sales Lead", "/entities/salesLeadEntity/Create.xhtml"),
        EditSalesLead("Edit Sales Lead", "/entities/salesLeadEntity/Edit.xhtml"),
        ViewAllSalesLead("View All Sales Lead", "/entities/salesLeadEntity/List.xhtml"),
        ViewSalesLeadHistory("View Sales Lead History", "/entities/salesLeadEntity/SalesLeadHistory.xhtml"),
        //SearchSalesLead("Search Sales Lead", "/entities/salesLeadEntity/Search.xhtml"),
        DeleteSalesLead("Delete Sales Lead", ""),
        ConvertSalesLead("Convert Sales Lead", "/entities/salesLeadEntity/ConvertView.xhtml"),
        //customer
        AddCustomer("Add Customer", "/entities/customerEntity/Create.xhtml"),
        EditCustomer("Edit Customer", "/entities/customerEntity/Edit.xhtml"),
        ViewAllCustomer("View All Customer", "/entities/customerEntity/List.xhtml"),
        ViewCustomerExecutiveCustomer("View Customer Executive Customers", "/entities/customerEntity/CustomerExecutiveCustomersList.xhtml"),
        ViewCustomerHistory("View Customer History", "/entities/customerEntity/CustomerHistory.xhtml"),
        //SearchCustomer("Search Customer", "/entities/customerEntity/Search.xhtml"),
        DeleteCustomer("Delete Customer", ""),
        //Access Control
        ModifyRoles("Modify Roles", "/roles/EditRoles.xhtml"),
        AssignRight("Modify Rights", "/roles/ViewRight.xhtml"),
        AssignRole("Assign Role", "/roles/Department.xhtml"),
        UnlockUser("Unlock User", "/roles/UnlockUser.xhtml"),
        //PriceList
        AddPriceList("Add Price List", "/entities/priceListEntity/Create.xhtml"),
        EditPriceList("Edit Price List", "/entities/priceListEntity/Edit.xhtml"),
        ViewPriceList("View Price List", "/entities/priceListEntity/View.xhtml"),
        ViewAllPriceList("View All Price List", "/entities/priceListEntity/List.xhtml"),
        DeletePriceList("Delete Price List", ""),
        //Sales Inquiry
        AddSalesInquiry("Add Sales Inquiry", "/entities/salesInquiryEntity/Create.xhtml"),
        ConvertSalesInquiry("Edit Sales Inquiry", "/entities/salesInquiryEntity/Edit.xhtml"),
        ViewAllSalesInquiry("View All Sales Inquiry", "/entities/salesInquiryEntity/List.xhtml"),
        SearchSalesInquiry("Search Sales Inquiry", "/entities/salesInquiryEntity/Search.xhtml"),
        ViewSalesInquiry("View Sales Inquiry", "/entities/salesInquiryEntity/View.xhtml"),
        DeleteSalesInquiry("Delete Sales Inquiry", ""),
        //Sales Quotation
        AddSalesQuotation("Add Sales Quotation", "/entities/salesQuotationEntity/Create.xhtml"),
        EditSalesQuotation("Edit Sales Quotation", "/entities/salesQuotationEntity/Edit.xhtml"),
        SetSalesQuotationLeadTime("Set Sales Quotation Lead Time", "/entities/salesQuotationEntity/LeadTime.xhtml"),
        ViewAllSalesQuotation("View All Sales Quotation", "/entities/salesQuotationEntity/List.xhtml"),
        ViewUnquotedSalesQuotation("View Unquoted Sales Quotation", "/entities/salesQuotationEntity/Notquoted.xhtml"),
        QuoteSalesQuotation("Quote Sales Quotation", "/entities/salesQuotationEntity/Quote.xhtml"),
        SearchSalesQuotation("Search Sales Quotation", "/entities/salesQuotationEntity/Search.xhtml"),
        ViewSalesQuotation("View Sales Quotation", "/entities/salesQuotationEntity/View.xhtml"),
        DeleteSalesQuotation("Delete Sales Quotation", ""),
        //Purchase Order
        AddPurchaseOrder("Add Purchase Order", "/entities/purchaseOrderEntity/Create.xhtml"),
        EditPurchaseOrder("Edit Purchase Order", "/entities/purchaseOrderEntity/Edit.xhtml"),
        ViewAllPurchaseOrder("View All Purchase Order", "/entities/purchaseOrderEntity/List.xhtml"),
        SearchPurchaseOrder("Search Purchase Order", "/entities/purchaseOrderEntity/Search.xhtml"),
        ViewPurchaseOrder("View Purchase Order", "/entities/purchaseOrderEntity/View.xhtml"),
        DeletePurchaseOrder("Delete Purchase Order", ""),
        ReviewPurchaseOrder("ReviewPurchaseOrder", "/entities/purchaseOrderEntity/Review.xhtml"),
        //SalesOrder
        AddSalesOrder("Add Sales Order", "/entities/salesOrderEntity/Create.xhtml"),
        EditSalesOrder("Edit Sales Order", "/entities/salesOrderEntity/Edit.xhtml"),
        ViewSalesOrder("View Sales Order", "/entities/salesOrderEntity/View.xhtml"),
        SearchSalesOrder("Search Sales Order", "/entities/salesOrderEntity/Search.xhtml"),
        ViewAllSalesOrder("View All Sales Order", "/entities/salesOrderEntity/List.xhtml"),
        DeleteSalesOrder("Delete Sales Order", ""),
        ViewAllSalesOrderReport("View All Sales Order Report", "/entities/saleOrderReportEntity/List.xhtml"),
        //Sales Planning
        ViewAllSalesForecast("View All Sales Forecast", "/entities/salesForecastEntity/List.xhtml"),
        CreateNewSalesForecast("Create New Sales Forecast", "/entities/salesForecastEntity/Create.xhtml"),
        DeleteSalesForecast("Delete Sales Forecast", ""),
        EditSalesForecast("Edit Sales Forecast", "/entities/salesForecastEntity/Edit.xhtml"),
        CreateNewMarketSalesReport("Create new market sales report", "/entities/marketSalesReportEntity/Create.xhtml"),
        EditMarketSalesReport("Edit market sales report", "/entities/marketSalesReportEntity/Edit.xhtml"),
        DeleteMarketSalesReport("Delete market sales report", ""),
        ViewAllMarketSalesReports("View market sales reports", "/entities/marketSalesReportEntity/List.xhtml"),
        //Employee Management
        ViewSystemUser("View SystemUser", "/entities/systemUserEntity/View.xhtml"),
        EditSystemUser("Edit SystemUser", "/entities/systemUserEntity/Edit.xhtml"),
        CreateSystemUser("Create SystemUser", "/entities/systemUserEntity/Register.xhtml"),
        DeactivateActivateSystemUser("Deactivate Activate SystemUser", "/entities/systemUserEntity/List.xhtml"),
        SearchSystemUser("Search System User", "/entities/systemUserEntity/ListSearchResults.xhtml"),
        ListSystemUser("List System User", "/entities/systemUserEntity/List.xhtml"),
        //Internal Message
        ViewUserMessage("View UserMessage", "/entities/internalMessageEntity/UserMessage.xhtml"),
        CreateEditDeleteUserMessage("Create Edit Delete UserMessage", "/entities/internalMessageEntity/UserMessage.xhtml"),
        ViewAnnouncement("View Announcement", "/entities/internalMessageEntity/Announcement.xhtml"),
        CreateEditDeleteAnnouncement("Create Edit Delete Announcement", "/entities/internalMessageEntity/Announcement.xhtml"),
        ViewSystemMessage("View SystemMessage", "/main"),
        //User Account
        ViewAccount("View Account", "/entities/contactEntity/ViewContact.xhtml"),
        EditAccount("Edit Account", "/entities/contactEntity/EditContact.xhtml"),
        //Customer Account
        ListAllCustomerAccounts("List All Customer Accounts", "/entities/customerAccountEntity/List.xhtml"),
        ViewCustomerAccount("View Customer Account", "/entities/customerAccountEntity/View.xhtml"),
        AssignCustomerAccount("Assign Customer Account", "/entities/customerAccountEntity/NoAccountCustomersList.xhtml"),
        CreateEditCreditTerm("Create & Edit Credit Term", "/entities/creditTermEntity/Create.xhtml"),
        //Production Planning
        AddProductionPlan("Add Production Plan", "/entities/masterProductionScheduleMonthlyEntity/Create.xhtml"),
        ViewProductionPlan("View Production Plan", "/entities/masterProductionScheduleMonthlyEntity/View.xhtml"),
        ListProductionPlan("List Production Plan", "/entities/masterProductionScheduleMonthlyEntity/List.xhtml"),
        EditProductionPlan("Edit Production Plan", "/entities/masterProductionScheduleMonthlyEntity/Edit.xhtml"),
        ListMRPS("List Material Requirement Plan", "/entities/rawMaterialRequirementWeeklyEntity/List.xhtml"),
        CreateNewMRP("Create Material Requirement Plan", "/entities/rawMaterialRequirementWeeklyEntity/Create.xhtml"),
        ListAllBackOrders("List Back Orders", "/entities/backorderEntity/List.xhtml"),
        EditBackOrder("Edit Back Order", "/entities/backorderEntity/Edit.xhtml"),
        ListAllCompletedGoods("List Completed Goods", "/entities/completedGoodsEntity/List.xhtml"),
        CreateNewCompletedGood("Create new complete good", "/entities/completedGoodsEntity/Create.xhtml"),
        ViewCompletedGood("View completed good", "/entities/completedGoodsEntity/View.xhtml"),
        DeleteCompletedGood("Delete Completed Good", ""),
        EditCompletedGood("Edit Completed Good", "/entities/completedGoodsEntity/Edit.xhtml"),
        ListAllRawMaterials("List all raw materials", "/entities/rawMaterialEntity/List.xhtml"),
        CreateNewRawMaterial("Create new raw material", "/entities/rawMaterialEntity/Create.xhtml"),
        EditRawMaterial("Edit raw material", "/entities/rawMaterialEntity/Edit.xhtml"),
        DeleteRawMaterial("Delete raw material", ""),
        ViewRawMaterial("View Raw Material", "/entities/rawMaterialEntity/View.xhtml"),
        DeleteMRP("Delete MRP", "/entities/rawMaterialRequirementWeeklyEntity/Delete.xhtml"),
        PublicHoliday("Public Holiday", "/entities/calendarEntity/List.xhtml"),

        //Inventory Management
        AddNewBatch("Add New Batch", "/entities/batchEntity/Create.xhtml"),
        ViewCGInventoryOverview("View CG Inventory Overview", "/entities/completedGoodsEntity/CompletedGoodsByLocation.xhtml"),
        ViewRMInventoryOverview("View RM Inventory Overview", "/entities/rawMaterialEntity/RawMaterialsByLocation.xhtml"),
        ViewCGInventoryLog("View CG Inventory Log", "/entities/completedGoodsEntity/CompletedGoodsLog.xhtml"),
        ViewRMInventoryLog("View RM Inventory Log", "/entities/rawMaterialEntity/RawMaterialsLog.xhtml"),
        ViewAllPickingOrders("View All Picking Orders", "/entities/pickingOrderEntity/List.xhtml"),
        ViewAllReservations("View All Reservations", "/entities/reservationEntity/List.xhtml"),
        OutBoundRM("Outbound Raw Materials", "/entities/rawMaterialEntity/RawMaterialOutbound.xhtml"),
        MakeReservation("Make Reservation", ""),
        ViewAllReservation("View All Reservation", "/entities/reservationEntity/List.xhtml"),
        ViewInventoryMenu("View Inventory Menu", ""),
        InventoryUtilizationReport("Inventory Utilization Report", ""),
        ShippingPacking("Shipping & Packing", "/entities/shippingOrderEntity/List.xhtml"),
        ViewPacking("View Packing Order", "/entities/packingOrderEntity/View.xhtml"),
        
        //Raw material
        AddSupplier("Add Suplier", Folder.purchasing, "AddSupplier.xhtml"),
        ListSupplier("List Supplier", Folder.purchasing, "ListSupplier.xhtml"),
        CreatePurchaseRequisition("CreatePurchaseRequisition", Folder.purchasing, "PurchaseRequisition.xhtml"),
        MaintainQuotation("MaintainQuotation", Folder.purchasing, "MaintainQuotation.xhtml"),
        InitiateOrder("Initiate Order", Folder.purchasing, "PriceComparison.xhtml"),
        UpdateOrder("Update Order", Folder.purchasing, "EditOrder.xhtml"),
        MaintainOngoingOrder("MaintainOngoingOrder", Folder.purchasing, "OrderHistory.xhtml"),
        AcknowledgeNewOrder("AcknowledgeNewOrder", Folder.purchasing, "AcknowledgeOrder.xhtml"),
        ViewCompletedOrder("ViewCompletedOrder", Folder.purchasing, "PastOrder.xhtml"),
        //accounts receivable
        Invoices("Invoice", "/entities/customerInvoiceEntity/ListUnposted.xhtml"),
        BillingRequest("Billing Request", "/entities/billingRequestEntity/ListCIA.xhtml"),
        Payment("payment", "/entities/paymentEntity/ListCIA.xhtml"),
        ViewInvoice("view invoice", "/entities/customerInvoiceEntity/ViewOnly.xhtml"),
        //account payable
        Refund("Refund", "/entities/refundRequestEntity/List.xhtml"),
        MaintainNewInvoice("MaintainNewInvoice", Folder.purchasing, "NewInvoice.xhtml"),
        PostInvoice("Post Invoice", Folder.purchasing, "PostPayment.xhtml");

        static {
            AddSupplier.addLink("/entities/purchasing/Edit.xhtml");
            CreatePurchaseRequisition.addLink("/entities/purchasing/PurchaseRequisitionInfo.xhtml");
            AcknowledgeNewOrder.addLink("/entities/purchasing/MaintainOrder.xhtml");
            ViewCompletedOrder.addLink("/entities/purchasing/RateOrder.xhtml");
            MaintainQuotation.addLink("/entities/purchasing/EditQuotation.xhtml");
            PostInvoice.addLink("/entities/purchasing/OrderInvoiceDetail.xhtml");
            PostInvoice.addLink("/entities/purchasing/ViewPastInvoice.xhtml");
            MaintainNewInvoice.addLink("/entities/purchasing/InvoiceDetail.xhtml");
            ViewCompletedOrder.addLink("/entities/purchasing/ViewPastOrder.xhtml");

            UpdateOrder.addLink("/entities/purchasing/OrderDetail.xhtml");
            //sales
            //SearchSalesLead.addLink("/entities/salesLeadEntity/SearchList.xhtml");
            ConvertSalesLead.addLink("/entities/customerEntity/List.xhtml");
            //SearchCustomer.addLink("/entities/customerEntity/SearchList.xhtml");

            //Warehouse
            AddNewBatch.addLink("/entities/inventoryEntity/CreateCG.xhtml");
            AddNewBatch.addLink("/entities/inventoryEntity/CreateRM.xhtml");
            ShippingPacking.addLink("/entities/packingOrderEntity/View.xhtml");
            
            AddCustomer.addLink("/entities/customerEntity/List.xhtml");
            ViewAllCustomer.addLink("/entities/customerEntity/View.xhtml");
            ViewAllCustomer.addLink("/entities/customerEntity/CustomerExecutiveCustomersList.xhtml");
            ViewAllCustomer.addLink("/entities/customerEntity/SearchList.xhtml");
            ViewAllCustomer.addLink("/entities/customerEntity/Search.xhtml");

            ViewAllSalesLead.addLink("/entities/salesLeadEntity/View.xhtml");
            ViewAllSalesLead.addLink("/entities/salesLeadEntity/Search.xhtml");
            ViewAllSalesLead.addLink("/entities/salesLeadEntity/SearchList.xhtml");
            //Employee Management
            CreateSystemUser.addLink("/entities/systemUserEntity/Confirm.xhtml");
            //Internal Message
            ViewUserMessage.addLink("/entities/internalMessageEntity/ViewUserMessage.xhtml");
            ViewAnnouncement.addLink("/entities/internalMessageEntity/ViewAnnouncement.xhtml");
            ViewSystemMessage.addLink("/entities/internalMessageEntity/SystemMessage.xhtml");

            //Sales
            AddSalesInquiry.addLink("/entities/salesInquiryEntity/ViewCreate.xhtml");
            SearchSalesInquiry.addLink("/entities/salesInquiryEntity/SearchList.xhtml");
            AddSalesQuotation.addLink("/entities/salesQuotationEntity/ViewCreate.xhtml");
            SearchSalesQuotation.addLink("/entities/salesQuotationEntity/SearchList.xhtml");
            SearchPurchaseOrder.addLink("/entities/purchaseOrderEntity/SearchList.xhtml");
            AddSalesOrder.addLink("/entities/salesOrderEntity/View.xhtml");
            SearchSalesOrder.addLink("/entities/salesOrderEntity/SearchList.xhtml");
            ViewSalesOrder.addLink("/entities/salesOrderEntity/ViewTab.xhtml");
            ViewSalesOrder.addLink("/entities/salesOrderEntity/ViewExpanded.xhtml");
            ViewSalesOrder.addLink("/entities/shippingOrderEntity/ListForSO.xhtml");
            ViewAllSalesOrderReport.addLink("/entities/salesOrderEntity/View.xhtml");

            //Sales Planning
            ViewAllSalesForecast.addLink("/entities/salesForecastEntity/View.xhtml");
            EditSalesForecast.addLink("/entities/salesForecastEntity/UpdateForecastView.xhtml");
            ViewAllSalesForecast.addLink("/entities/salesForecastEntity/MonthlyAnalysis.xhtml");
            //Production Planning
            ListMRPS.addLink("/entities/rawMaterialRequirementWeeklyEntity/ListMrpsThisMonth.xhtml");
            ListMRPS.addLink("/entities/rawMaterialRequirementWeeklyEntity/ListMrpsThisMonthForThisRawMaterial.xhtml");
            ListAllBackOrders.addLink("/entities/backorderEntity/View.xhtml");
            EditBackOrder.addLink("/entities/backorderEntity/ApproveView.xhtml");
            EditProductionPlan.addLink("/entities/masterProductionScheduleWeeklyEntity/Edit.xhtml");
            EditProductionPlan.addLink("/entities/masterProductionScheduleDailyEntity/Edit.xhtml");

            //Customer Account
            AssignCustomerAccount.addLink("/entities/customerAccountEntity/Create.xhtml");
            AssignCustomerAccount.addLink("/entities/customerAccountEntity/List.xhtml");
            CreateEditCreditTerm.addLink("/entities/customerAccountEntity/Edit.xhtml");

            //Access Control
            ModifyRoles.addLink("/roles/Right.xhtml");
            AssignRight.addLink("/roles/UserRight.xhtml");
            AssignRole.addLink("/roles/ViewRole.xhtml");
            AssignRole.addLink("/roles/UserRole.xhtml");

            //User Account
            EditAccount.addLink("/entities/contactEntity/ChangePassword.xhtml");

            //Accounts Receivable
            Invoices.addLink("/entities/customerInvoiceEntity/ListCIA.xhtml");
            Invoices.addLink("/entities/customerInvoiceEntity/ListNormal.xhtml");
            Invoices.addLink("/entities/customerInvoiceEntity/ListReminder.xhtml");
            Invoices.addLink("/entities/customerInvoiceEntity/List.xhtml");
            BillingRequest.addLink("/entities/billingRequestEntity/ListNormal.xhtml");
            Payment.addLink("/entities/paymentEntity/ListNormal.xhtml");
            Payment.addLink("/entities/paymentEntity/List.xhtml");
            Payment.addLink("/entities/paymentEntity/ListLate.xhtml");
            Payment.addLink("/entities/customerInvoiceEntity/ListUnpaid.xhtml");
            Refund.addLink("/entities/refundRequestEntity/ListUnprocessed.xhtml");

        }
        private final String name;
        private final HashSet<String> links = new HashSet<String>();
        private Folder folder;

        Right(String name, Folder folder, String link) {
            this.name = name;
            this.folder = folder;
            String link1 = "/entities/" + folder.toString() + "/" + link;

            this.links.add(link1);

        }

        Right(String name, String link) {
            this.name = name;
            this.links.add(link);

        }

        public String getName() {
            return name;
        }

        public HashSet<String> getLinks() {
            return links;
        }

        public void addLink(String link) {
            links.add(link);
        }

        public Folder getFolder() {
            return folder;
        }

        public void setFolder(Folder folder) {
            this.folder = folder;
        }
    }

    public static enum Role {

        /*External*/
        SalesLead("Sales Lead"),
        Customer("Customer"),
        /*Internal*/
        //general
        Manager("Manager"),
        Employee("Employee"),
        //Sales
        CustomerExecutive("Customer Executive"),
        SalesManager("Sales Manager"),
        //IT     
        ApplicationDev("Application Dev"),
        ITAdmin("ITAdmin"),
        ITManager("ITManager"),
        //Finance
        AccountsReceivableManager("Account Receivable Manager"),
        AccountsReceivableEmployee("Accounts Receivable"),
        AccountsPayableEmployee("Accounts Payable"),
        AccountsPayableManager("Accounts Payable Manager"),
        //Marketing
        MarketingEmployee("Marketing"),
        //SalesPlanning
        SalesPlanningEmployee("Sales Planning"),
        SalesPlanningManager("SalesPlanning Manager"),
        //ProductionPlanning
        ProductionPlanningEmployee("Production Planning"),
        ProductionManager("Production Manager"),
        //FactoryFloor
        FactoryFloorEmployee("Factory Floor"),
        //Warehouse        
        WarehouseEmployee("Warehouse"),
        //Purchasing
        PurchasingEmployee("Purchasing");
        //     PurchasingManager("Purchasing Manager");
//        InventoryEmployee("Inventory"),
//        InventoryManager("Inventory Manager");

        static {

            //Inventory Management
//            InventoryManager.addRight(Right.AddNewBatch);
//            InventoryManager.addRight(Right.ViewInventoryOverview);
            WarehouseEmployee.addRight(Right.AddNewBatch);
            WarehouseEmployee.addRight(Right.ViewRMInventoryOverview);
            WarehouseEmployee.addRight(Right.ViewCGInventoryOverview);
            WarehouseEmployee.addRight(Right.ViewCGInventoryLog);
            WarehouseEmployee.addRight(Right.ViewRMInventoryLog);
            WarehouseEmployee.addRight(Right.ViewAllPickingOrders);
            WarehouseEmployee.addRight(Right.OutBoundRM);
            WarehouseEmployee.addRight(Right.MakeReservation);
            WarehouseEmployee.addRight(Right.ViewInventoryMenu);
            WarehouseEmployee.addRight(Right.ViewAllReservation);
            WarehouseEmployee.addRight(Right.InventoryUtilizationReport);
            WarehouseEmployee.addRight(Right.ShippingPacking);

            PurchasingEmployee.addRight(Right.AddSupplier);
            PurchasingEmployee.addRight(Right.ListSupplier);
            PurchasingEmployee.addRight(Right.CreatePurchaseRequisition);
            PurchasingEmployee.addRight(Right.MaintainQuotation);
            PurchasingEmployee.addRight(Right.InitiateOrder);
            PurchasingEmployee.addRight(Right.UpdateOrder);
            PurchasingEmployee.addRight(Right.MaintainOngoingOrder);
            PurchasingEmployee.addRight(Right.AcknowledgeNewOrder);

            PurchasingEmployee.addRight(Right.ViewCompletedOrder);
            PurchasingEmployee.addRight(Right.ViewAccount);
            PurchasingEmployee.addRight(Right.EditAccount);
            PurchasingEmployee.addRight(Right.ListAllBackOrders);
            PurchasingEmployee.addRight(Right.ListMRPS);


            SalesLead.addRight(Right.AddSalesInquiry);
            SalesLead.addRight(Right.ViewSalesInquiry);
            SalesLead.addRight(Right.ConvertSalesInquiry);
            SalesLead.addRight(Right.AddSalesQuotation);
            SalesLead.addRight(Right.ViewSalesQuotation);
            SalesLead.addRight(Right.EditSalesQuotation);
            SalesLead.addRight(Right.AddPurchaseOrder);
            SalesLead.addRight(Right.ViewPurchaseOrder);
            SalesLead.addRight(Right.EditPurchaseOrder);
            SalesLead.addRight(Right.ViewAccount);
            SalesLead.addRight(Right.EditAccount);
            SalesLead.addRight(Right.ViewAllSalesInquiry);
            SalesLead.addRight(Right.ViewAllSalesOrder);
            SalesLead.addRight(Right.ViewAllSalesQuotation);
            SalesLead.addRight(Right.ViewAllPurchaseOrder);

            Customer.addRight(Right.AddSalesInquiry);
            Customer.addRight(Right.ViewSalesInquiry);
            Customer.addRight(Right.ConvertSalesInquiry);
            Customer.addRight(Right.AddSalesQuotation);
            Customer.addRight(Right.ViewSalesQuotation);
            Customer.addRight(Right.EditSalesQuotation);
            Customer.addRight(Right.AddPurchaseOrder);
            Customer.addRight(Right.ViewPurchaseOrder);
            Customer.addRight(Right.EditPurchaseOrder);
            Customer.addRight(Right.ViewAccount);
            Customer.addRight(Right.EditAccount);

            //Sales 
            ITAdmin.addRight(Right.AssignRole);
            ITAdmin.addRight(Right.AssignRight);
            ITAdmin.addRight(Right.UnlockUser);
            ITManager.addRight(Right.ModifyRoles);

            //Sales
            CustomerExecutive.addRight(Right.AddSalesLead);
            CustomerExecutive.addRight(Right.EditSalesLead);
            CustomerExecutive.addRight(Right.ViewAllSalesLead);
            CustomerExecutive.addRight(Right.ViewSalesLeadHistory);
            //CustomerExecutive.addRight(Right.SearchSalesLead);
            CustomerExecutive.addRight(Right.AddCustomer);
            CustomerExecutive.addRight(Right.EditCustomer);
            CustomerExecutive.addRight(Right.ViewCustomerHistory);
            //CustomerExecutive.addRight(Right.SearchCustomer);
            CustomerExecutive.addRight(Right.ViewCustomerExecutiveCustomer);
            //Sales Inquiry
            CustomerExecutive.addRight(Right.AddSalesInquiry);
            CustomerExecutive.addRight(Right.ConvertSalesInquiry);
            CustomerExecutive.addRight(Right.ViewSalesInquiry);
            CustomerExecutive.addRight(Right.ViewAllSalesInquiry);
            CustomerExecutive.addRight(Right.SearchSalesInquiry);
            //Sales Quotation
            CustomerExecutive.addRight(Right.AddSalesQuotation);
            CustomerExecutive.addRight(Right.EditSalesQuotation);
            CustomerExecutive.addRight(Right.ViewSalesQuotation);
            CustomerExecutive.addRight(Right.ViewAllSalesQuotation);
            CustomerExecutive.addRight(Right.SearchSalesQuotation);
            CustomerExecutive.addRight(Right.ViewUnquotedSalesQuotation);
            CustomerExecutive.addRight(Right.QuoteSalesQuotation);
            //Purchase Order
            CustomerExecutive.addRight(Right.AddPurchaseOrder);
            CustomerExecutive.addRight(Right.EditPurchaseOrder);
            CustomerExecutive.addRight(Right.ViewAllPurchaseOrder);
            CustomerExecutive.addRight(Right.SearchPurchaseOrder);
            CustomerExecutive.addRight(Right.ViewPurchaseOrder);
            CustomerExecutive.addRight(Right.ReviewPurchaseOrder);
            //Sales Order
            CustomerExecutive.addRight(Right.AddSalesOrder);
            CustomerExecutive.addRight(Right.EditSalesOrder);
            CustomerExecutive.addRight(Right.ViewSalesOrder);
            CustomerExecutive.addRight(Right.SearchSalesOrder);
            CustomerExecutive.addRight(Right.ViewAllSalesOrder);
            CustomerExecutive.addRight(Right.ViewPacking);
            CustomerExecutive.addRight(Right.ViewInvoice);
            //PriceList
            CustomerExecutive.addRight(Right.ViewAllPriceList);
            CustomerExecutive.addRight(Right.ViewPriceList);

            SalesManager.addRight(Right.DeleteCustomer);
            SalesManager.addRight(Right.DeleteSalesLead);
            SalesManager.addRight(Right.DeleteSalesInquiry);
            SalesManager.addRight(Right.DeleteSalesQuotation);
            SalesManager.addRight(Right.DeletePurchaseOrder);
            SalesManager.addRight(Right.DeleteSalesOrder);
            SalesManager.addRight(Right.AddPriceList);
            SalesManager.addRight(Right.EditPriceList);
            SalesManager.addRight(Right.DeletePriceList);
            SalesManager.addRight(Right.ViewAllSalesOrderReport);
            SalesManager.addRight(Right.ConvertSalesLead);
            SalesManager.addRight(Right.ViewAllCustomer);

            //Sales Planning
            SalesPlanningManager.addRight(Right.ViewAllSalesForecast);
            SalesPlanningManager.addRight(Right.CreateNewSalesForecast);
            SalesPlanningManager.addRight(Right.DeleteSalesForecast);
            SalesPlanningManager.addRight(Right.EditSalesForecast);
            SalesPlanningManager.addRight(Right.CreateNewMarketSalesReport);
            SalesPlanningManager.addRight(Right.EditMarketSalesReport);
            SalesPlanningManager.addRight(Right.DeleteMarketSalesReport);
            SalesPlanningManager.addRight(Right.ViewAllMarketSalesReports);
            //Production Planning
            ProductionManager.addRight(Right.AddProductionPlan);
            ProductionManager.addRight(Right.ViewProductionPlan);
            ProductionManager.addRight(Right.ListProductionPlan);
            ProductionManager.addRight(Right.ListMRPS);
            ProductionManager.addRight(Right.CreateNewMRP);
            ProductionManager.addRight(Right.ViewAllSalesForecast);
            ProductionManager.addRight(Right.ListAllBackOrders);
            ProductionManager.addRight(Right.EditBackOrder);
            ProductionManager.addRight(Right.ListAllCompletedGoods);
            ProductionManager.addRight(Right.CreateNewCompletedGood);
            ProductionManager.addRight(Right.DeleteCompletedGood);
            ProductionManager.addRight(Right.EditCompletedGood);
            ProductionManager.addRight(Right.ListAllRawMaterials);
            ProductionManager.addRight(Right.CreateNewRawMaterial);
            ProductionManager.addRight(Right.EditRawMaterial);
            ProductionManager.addRight(Right.DeleteRawMaterial);
            ProductionManager.addRight(Right.ViewCompletedGood);
            ProductionManager.addRight(Right.ViewRawMaterial);
            ProductionManager.addRight(Right.DeleteMRP);
            ProductionManager.addRight(Right.EditProductionPlan);
            ProductionManager.addRight(Right.PublicHoliday);

            //Finance
            AccountsReceivableEmployee.addRight(Right.AssignCustomerAccount);
            AccountsReceivableEmployee.addRight(Right.ViewCustomerAccount);
            AccountsReceivableManager.addRight(Right.CreateEditCreditTerm);
            AccountsReceivableManager.addRight(Right.ListAllCustomerAccounts);
            AccountsReceivableEmployee.addRight(Right.Invoices);
            AccountsReceivableEmployee.addRight(Right.BillingRequest);
            AccountsReceivableEmployee.addRight(Right.Payment);
            CustomerExecutive.addRight(Right.ViewCustomerAccount);

            //TODO: changed to payable
            AccountsPayableEmployee.addRight(Right.Refund);
            AccountsPayableEmployee.addRight(Right.MaintainNewInvoice);
            AccountsPayableEmployee.addRight(Right.PostInvoice);

            //Manager
            Manager.addRight(Right.CreateEditDeleteAnnouncement);

            //Employee
            Employee.addRight(Right.ViewAnnouncement);
            Employee.addRight(Right.CreateEditDeleteUserMessage);
            Employee.addRight(Right.ViewUserMessage);
            Employee.addRight(Right.ViewSystemMessage);

            Employee.addRight(Right.ViewSystemUser);
            Employee.addRight(Right.ListSystemUser);
            Employee.addRight(Right.SearchSystemUser);

            Employee.addRight(Right.ViewAccount);
            Employee.addRight(Right.EditAccount);

            ITAdmin.addRight(Right.CreateSystemUser);
            ITAdmin.addRight(Right.DeactivateActivateSystemUser);
            ITAdmin.addRight(Right.EditSystemUser);

        }
        private final String name;
        private final HashSet<Right> rights = new HashSet<Right>();

        Role(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void addRight(Right right) {
            this.rights.add(right);
        }

        public HashSet<Right> getRights() {
            return rights;
        }
    }

    public static enum Department {

        Sales("Sales", Role.CustomerExecutive),
        Marketing("Marketing", Role.MarketingEmployee),
        SalesPlanning("Sales Planning", Role.SalesPlanningEmployee),
        ProductionPlanning("Production Planning", Role.ProductionPlanningEmployee),
        FactoryFloor("Factory Floor", Role.FactoryFloorEmployee),
        AccountsReceivable("Accounts Receivable", Role.AccountsReceivableEmployee),
        AccountsPayable("Accounts Payable", Role.AccountsPayableEmployee),
        Warehouse("Warehouse", Role.WarehouseEmployee),
        Purchasing("Purchasing", Role.PurchasingEmployee),
        TechnicalSupport("Technical Support", Role.ITAdmin),
        ApplicationDevelopment("Application Development", Role.ApplicationDev);
        private final String name;
        private final Role defaultRole;

        Department(String name, Role defaultRole) {
            this.name = name;
            this.defaultRole = defaultRole;
        }

        public String getName() {
            return name;
        }

        public Role getDefaultRole() {
            return defaultRole;
        }
    }

    public static enum CreditTerm {

        Default(2000, 30, 0.05, 10, 0.02);
        final double creditLimit;
        final int maxRepayTime;
        final double lateCharges;
        final int discountRepayTime;
        final double discount;
        long dbId;

        private CreditTerm(double creditLimit, int maxRepayTime, double lateCharges,
                int discountRepayTime, double discount) {
            this.creditLimit = creditLimit;
            this.maxRepayTime = maxRepayTime;
            this.lateCharges = lateCharges;
            this.discountRepayTime = discountRepayTime;
            this.discount = discount;
        }

        public void setDbId(long dbId) {
            this.dbId = dbId;
        }

        public long getDbId() {
            return dbId;
        }
    }

    public static enum RawMaterial {

        Oats("Oats", 2, 12, 100, 22000),
        WheatGerm("Wheat Germ", 2, 12, 20, 2500),
        Cinnamon("Cinnamon", 2, 12, 20,600),
        Nutmeg("Nutmeg", 2, 12, 20, 300),
        Cloves("Cloves", 2, 12, 20, 150),
        Honey("Honey", 2, 12, 20, 2200),
        CanolaOil("Canola Oil", 2, 12, 20, 800),
        VitMineralPowder("Vitamin/Mineral Powder", 2, 12, 10, 680),
        CarobChips("Carob Chips", 2, 12, 20, 3300),
        ProteinPowder("Protein Powder", 2, 12, 10, 2600),
        CocoaPowder("Cocoa Powder", 1, 24, 20, 1800),
        Hazenuts("Hazenuts", 2, 24, 50, 2300),
        Cashewnuts("Cashew Nuts", 2, 24, 50, 1800),
        Walnuts("Walnuts", 2, 24, 50, 1800),
        Almonds("Almonds", 2, 24, 50, 1300),
        Macadamias("Macadamias", 2, 24, 50, 1350),
        Redcurrants("Redcurrants", 3, 6, 50, 1900),
        Rasins("Rasins", 1, 12, 50, 1650),
        Dates("Dates", 1, 12, 50, 1500),
        Apricots("Apricots", 3, 6, 50, 1200),
        Kiwis("Kiwis", 3, 6, 50, 1300),
        Apples("Apples", 1, 6, 50, 920),
        Peaches("Peaches", 2, 12, 50, 1300);
        private final String productName;
        private int leadTime;
        private int shelfLife;
        private int lotSize;
        private long scheduleReciept; // for intialisation of MRP reports

        public int getLeadTime() {
            return leadTime;
        }

        public void setLeadTime(int leadTime) {
            this.leadTime = leadTime;
        }

        RawMaterial(String productName, int leadTime, int shelfLife, int lotSize, long reciepts) {
            this.productName = productName;
            this.shelfLife = shelfLife;
            this.lotSize = lotSize;
            this.leadTime = leadTime;
            scheduleReciept = reciepts;
        }

        public long getScheduleReciept() {
            return scheduleReciept;
        }

        public int getShelfLife() {
            return shelfLife;
        }

        public int getLotSize() {
            return lotSize;
        }

        public String getProductName() {
            return productName;
        }

        public static enum Supplier {

            Utc("ngan1", "ngan1", "UnitedNationHeaven"),
            Cll("ngan2", "ngan2", "UtcCorporationOfViet"),
            Quaker("ngan3", "ngan3", "USupplyOfAnyProduct"),
            Qu("ngan4", "ngan4", "UnionOfSovietSocialist");
            //Qu1("ngan5", "ngan5", "UnbeatableOrganization");
            private final String name;
            private final String companyName;
            private final String password;

            Supplier(String name, String password, String companyName) {
                this.name = name;
                this.password = password;
                this.companyName = companyName;

            }

            public String getName() {
                return name;
            }

            public String getCompanyName() {
                return companyName;
            }

            public String getPassword() {
                return password;
            }
        }
//    
//     public static enum Location {
//
//        A1("A1"),
//    
//        
//        private final String areaCode;
//        private final int usage;
//        private final int capacity;
//
//        Location(String areaCode, int usage, int capacity) {
//            this.areaCode = areaCode;
//            this.usage = 0;
//            this.capacity = 100;
//        }
//
//        public String getName() {
//            return name;
//        }
//
//        public Role getDefaultRole() {
//            return defaultRole;
//        }
//        
//    }
    }

    public enum Folder {

        purchasing,;
    }

    public enum CompletedGoods {

        NutriNuts("Classic Nutri Bar (Nuts)"),
        NutriFruits("Classic Nutri Bar (Fruits)"),
        PowerChoc("Premium Power Bar (Chocolate Nuts)"),
        powerRedcurr("Premium Power Bar (Redcurrant Fruits)");
        private final String name;
        private Long dbId;

        private CompletedGoods(String name) {
            this.name = name;
        }

        private CompletedGoods(String name, Long dbId) {
            this.name = name;
            this.dbId = dbId;
        }

        public Long getDbId() {
            return dbId;
        }

        public void setDbId(Long dbId) {
            this.dbId = dbId;
        }

        public String getName() {
            return name;
        }
    }

    public static CompletedGoods getCompletedGoodsByName(String name) {

        for (CompletedGoods goods : CompletedGoods.values()) {
            if (goods.name.equals(name)) {
                return goods;
            }
        }

        return null;
    }
}
